package demoenum;

/**
 * @Author 12629
 * @Description：
 */
public enum TestEnum {
    //RED,WHITE,GREEN,BLACK;

    RED(1,"red"),BLACK(2,"black"),
    WHITE(3,"white"),GREEN(4,"green");

    private int ordinal;
    private String color;

    //private 枚举的构造方法 默认是私有的
    TestEnum(int ordinal, String color) {
        this.ordinal = ordinal;
        this.color = color;
    }









    public static void main2(String[] args) {
        TestEnum[] values = TestEnum.values();
        for (int i = 0; i < values.length; i++) {
            System.out.print(values[i]+" "+values[i].ordinal()+" ");
        }
        System.out.println();
        System.out.println("=========");
        TestEnum testEnum = TestEnum.valueOf("GREEN");
        System.out.println(testEnum);
        System.out.println("=========");
        System.out.println(RED.compareTo(GREEN));
    }


    public static void main1(String[] args) {
        TestEnum testEnum = TestEnum.BLACK;
        switch (testEnum) {
            case RED:
                System.out.println("RED");
                break;
            case WHITE:
                System.out.println("WHITE");
                break;
            case GREEN:
                System.out.println("GREEN");
                break;
            case BLACK:
                System.out.println("BLACK");
                break;
            default:
                System.out.println("颜色不匹配");
                break;
        }
    }
}
